package com.jiazhong.shixi_bookstore.controller;

import com.jiazhong.shixi_bookstore.bean.Book;
import com.jiazhong.shixi_bookstore.mapper.BookMapper;
import com.jiazhong.shixi_bookstore.utll.JsonResult;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
@CrossOrigin("*")
@RestController
@RequestMapping("/book")
public class BookController {
    @Resource
    protected BookMapper bookMapper;
    @RequestMapping("/fresh_book")
    public JsonResult findByFreshBook() {
        List<Book> list = bookMapper.findFyFreshBook();
        JsonResult result = new JsonResult(true,200,list,"");
        return result;

    }
    @RequestMapping("/fresh_book_more")
    public JsonResult findByFreshBookMore() {
        List<Book> list = bookMapper.findFyFreshBookMore();
        JsonResult result = new JsonResult(true,200,list,"");
        return result;

    }
    @RequestMapping("/lower_book")
    public JsonResult findByLowerBook() {

        List<Book> list = bookMapper.findFyLowerBook();
        JsonResult result = new JsonResult(true,200,list,"");
        return result;
    }
    @RequestMapping("/lower_book_more")
    public JsonResult findByLowerBookMore() {

        List<Book> list = bookMapper.findFyLowerBookMore();
        JsonResult result = new JsonResult(true,200,list,"");
        return result;
    }
    @RequestMapping("/find_book_name")
    public JsonResult findByLikeName(String name) {
        List<Book> list = bookMapper.findByLikeName("%" + name + "%");
        JsonResult result = new JsonResult(true,200,list,"");
        return result;
    }
}
